package com.flyoil.petromp.adapter.adapter_matter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.flyoil.petromp.R;
import com.flyoil.petromp.base.BaseRecyAdapter;
import com.flyoil.petromp.entity.entity_matter.MatterSearchOrderConditionEntity;

/**
 * Created by Administrator on 2017/12/7 0007.
 * 单据筛选条件的适配器
 */

public class ItemMatterSearchConditionAdapter extends BaseRecyAdapter<ItemMatterSearchConditionAdapter.ViewHolder, MatterSearchOrderConditionEntity> {
    public ItemMatterSearchConditionAdapter(Context mContext) {
        super(mContext);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ItemMatterSearchConditionAdapter.ViewHolder(mInflater.inflate(R.layout.item_search_order_condition_adapter, parent, false));

    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
        final MatterSearchOrderConditionEntity entity = data.get(position);
        ViewHolder viewHolder = (ViewHolder) holder;
        viewHolder.tv_name.setText(entity.getName());
        viewHolder.img_icon.setImageResource(entity.getIcon());
        viewHolder.line.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (onItemClickListener != null) {
                    onItemClickListener.Onclick(position, entity);
                }
            }
        });
    }

    class ViewHolder extends RecyclerView.ViewHolder {
        private TextView tv_name;
        private ImageView img_icon;
        private LinearLayout line;

        public ViewHolder(View itemView) {
            super(itemView);
            tv_name = itemView.findViewById(R.id.tv_item_search_order_condition_name);
            img_icon = itemView.findViewById(R.id.img_item_search_order_condition_icon);
            line = itemView.findViewById(R.id.line_item_search_order_condition);
        }
    }
}
